www.gusucode.com > 循环自相关函数工具箱源码程序 > matlab代做 修改 程序循环自相关函数工具箱/cyclostationary_toolbox/synchronous_average.m
function m=synchronous_average(x,T) % % SYNCHRONOUS_AVERAGE % calculate the synchronous average of the signal x % with period T % % USAGE % m=synchronous_average(x,T) % % if T is a scalar, then T defined the fundamental % cyclic period % % if T is a vector, then T defines a series of once % per revolution impulses % File: synchronous_average.m % Last Revised: 24/11/97 % Created: 24/11/97 % Author: Andrew C. McCormick % (C) University of Strathclyde % Simple error checks if nargin~=2 error('Incorrect number of arguments for function synchronous_average'); end if T(1)<1 error('Synchronous period must be larger than 1 in function synchronous average'); end % Remove excess samples due to non-integer sampling if length(T)==1 % remove jitter samples if non-integer T if T~=floor(T) cp=1;np=1; while cp+T<length(x) cp=cp+floor(T); np=np+T; if (np-cp)>1 x=[x(1:cp-1) x(cp+1:length(x))]; np=np-1; end end end n=floor((length(x)-1)/T); else % extract time series correlated with periodic pulses rot_positions=T; T=floor(median(diff(rot_positions))); nx=[]; n=length(rot_positions)-2; for k=1:n; cp=rot_positions(k); nx=[nx; x(cp:cp+T-1)]; end x=nx; end temp=zeros(floor(T),n); t=(1:floor(T)*n); temp(:)=x(t); m=mean(temp');